#!/bin/bash


#系统准备
swapoff -a ##临时关闭，重启失效
sed -ri 's/.*swap.*/#&/' /etc/fstab ##永久关闭，需重启
sed -ri 's#(SELINUX=).*#\1disabled#' /etc/selinux/config  #off selinux
setenforce 0
systemctl disable firewalld
systemctl stop firewalld

#安装依赖
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2 bash-completion
#配置repo
yum-config-manager \
--add-repo \
https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

rpm --import https://mirrors.aliyun.com/docker-ce/linux/centos/gpg

#安装docker
yum install -y docker-ce docker-ce-cli containerd.io

#配置国内镜像加速
[ ! -d /etc/docker ] && mkdir /etc/docker/
[ ! -f /etc/docker/daemon.json ] && touch /etc/docker/daemon.json
echo -e "{\n  \"registry-mirrors\": [\"https://docker.mirrors.ustc.edu.cn\"]\n}\n" >> /etc/docker/daemon.json


systemctl daemon-reload
service docker restart

#重启服务
systemctl enable docker
systemctl restart docker

#安装docker-compose
yum install -y docker-compose
#验证
docker-compose --version
